<?php
namespace app\common\config\model;


use think\Model;
use think\model\concern\SoftDelete;

class ConfigStoreHall extends Model
{
    protected $table = "tk_config_store_hall";

    use SoftDelete;
    protected $defaultSoftDelete = 0;

    // BanquetBanner
    public function setBanquetBannerAttr($value){
        return json_encode($value);
    }
    public function getBanquetBannerAttr($value){
        return $value ? json_decode($value) : [];
    }

    // BanquetAlbum
    public function setBanquetAlbumAttr($value){
        return json_encode($value);
    }
    public function getBanquetAlbumAttr($value){
        return $value ? json_decode($value) : [];
    }

    // BirthdayBanner
    public function setBirthdayBannerAttr($value){
        return json_encode($value);
    }
    public function getBirthdayBannerAttr($value){
        return $value ? json_decode($value) : [];
    }

    // BirthdayAlbum
    public function setBirthdayAlbumAttr($value){
        return json_encode($value);
    }
    public function getBirthdayAlbumAttr($value){
        return $value ? json_decode($value) : [];
    }

    // MeetingBanner
    public function setMeetingBannerAttr($value){
        return json_encode($value);
    }
    public function getMeetingBannerAttr($value){
        return $value ? json_decode($value) : [];
    }

    // MeetingAlbum
    public function setMeetingAlbumAttr($value){
        return json_encode($value);
    }
    public function getMeetingAlbumAttr($value){
        return $value ? json_decode($value) : [];
    }

    // tags
    public function setTagsAttr($value){
        return json_encode($value);
    }

    public function getTagsAttr($value){
        return $value ? json_decode($value) : [];
    }

    public function getShapesAttr($value, $data)
    {
        $shapeModel = new ConfigHallShape();
        $where = [];
        $where[] = ['store_id', '=', $data['store_id']];
        $where[] = ['hall_id', '=', $data['id']];
        $rows = $shapeModel->field('id,shape,image,album')->where($where)->order('sort desc,id desc')->select();

        return $rows->isEmpty() ? [] : $rows;
    }

}